import sqlite3


def exeSql(sql):
    # 连接到SQLite数据库
    # 如果文件不存在，会自动在当前目录创建
    conn = sqlite3.connect(r'E:\Workspace\08-课件\07-接口测试\guest\db.sqlite3')
    cursor = conn.cursor()  # 创建一个Cursor
    try:
        cursor.execute(sql)  # 执行一条SQL语句
        results = cursor.fetchall()  # 获得查询结果集
        cursor.close()  # 关闭Cursor
        conn.commit()  # 提交事务
        return results
    except:
        conn.rollback()
    conn.close()  # 关闭Connection


sql1 = 'SELECT id FROM sign_event'
sql2 = "insert into sign_event values(6,'脑残',200,a.txt,'七天','2016-11-21 15:31:17','2016-11-21 15:31:25.158453')"
results = exeSql(sql2)
# print(results)
